﻿namespace ConsoleApp2;

class Program
{
    static void Main(string[] args)
    {
        //${字符串内插}
        string firstName = "Jay", greeting = "Hello", message = $"{firstName} {greeting}";
        Console.WriteLine(message);

        //将字符串内插与多个变量和文本字符串一起使用
        int version = 11;
        string updateText = "Update to Windows";
        string newText = $"{updateText} {version}";
        Console.WriteLine(newText);

        //合并逐字文本和字符串内插
        // string projectName = "First-Project";
        // Console.WriteLine($@"C:\Output\{projectName}\Data");

        //使用逐字字符串（@） 就不能使用 转义序列
        string projectName = "ACME";
        string englishLocation = $@"c:\Exercise\{projectName}\data.txt";
        Console.WriteLine($"View English output:\n\t\t{englishLocation}\n");

        string russianMessage =
            "\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434";
        string russianLocation = $@"c:\Exercise\{projectName}\ru-RU\data.txt";
        Console.WriteLine($"{russianMessage}:\n\t\t{russianLocation}\n");


        //隐式转换
        int widgetsSold = 7;
        //输出77
        Console.WriteLine(firstName + " sold " + widgetsSold + 7 + " widgets.");

        Console.WriteLine($"Modulus of 200 / 5 : {200 % 5}");
        Console.WriteLine($"Modulus of 7 / 5 : {7 % 5}");
        string age = $"Male {3 + 15} years old";

        // 对于括号运算符，你看到了三种用法：方法调用、运算顺序和强制转换。
        int first = 7;
        int second = 5;
        decimal quotient = (decimal)first / (decimal)second;
        Console.WriteLine(quotient);

        int fahrenheit = 94;
        Console.WriteLine($"The temperature is {(decimal)(fahrenheit - 32) * 5 / 9:F1} Celsius.");

    }
}